﻿package mortal.game.view.shopMall.shopQQ
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.platform.platformTencent.*;
    import mortal.mvc.core.*;

    public class ShopQQPointExchangeRender extends GCellRenderer
    {
        private var _shopItem:BaseItem;
        private var _yuanjia:GTextFiled;
        private var _xianjia:GTextFiled;
        private var _propName:GTextFiled;
        private var _oldPrice:GTextFiled;
        private var _price:GTextFiled;
        private var _buyBtn:GLoadingButton;
        private var _deleteLine:GBitmap;
        private var _listPriceIcon:GBitmap;
        private var _priceIcon:GBitmap;
        private var _numericStepper:GNumericStepper;
        private var _info:TTencentShop;

        public function ShopQQPointExchangeRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_1:GTextFormat = null;
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(5, 4, 240, 105, this, ImagesConst.GoodsBg));
            _loc_1 = GlobalStyle.textFormatlan.right();
            this._oldPrice = UIFactory.gTextField("", 145, 32, 60, 25, this, _loc_1);
            this._price = UIFactory.gTextField("", 145, 55, 60, 25, this, _loc_1);
            _loc_1 = GlobalStyle.textFormatBai.left();
            this._yuanjia = UIFactory.gTextField(Language.getString(35544), 90, 32, 160, 25, this, _loc_1, true);
            this._listPriceIcon = UIFactory.gBitmap("", 205, 32, this);
            this._deleteLine = UIFactory.gBitmap(ImagesConst.deleteLine, 180, 40, this);
            this._xianjia = UIFactory.gTextField(Language.getString(35545), 90, 55, 160, 25, this, _loc_1, true);
            this._priceIcon = UIFactory.gBitmap("", 205, 55, this);
            _loc_1 = GlobalStyle.textFormatBai;
            _loc_1.align = TextFormatAlign.CENTER;
            _loc_1.size = 14;
            _loc_1.bold = true;
            this._propName = UIFactory.gTextField("", 64, 6, 120, 25, this, _loc_1, true);
            this._shopItem = UICompomentPool.getUICompoment(BaseItem);
            this._shopItem.x = 11;
            this._shopItem.y = 33;
            this._shopItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this.addChild(this._shopItem);
            this._buyBtn = UIFactory.gLoadingButton(ResFileConst.ShopMallBuyBtn, 175, 78, 51, 24, this);
            this._buyBtn.configEventListener(MouseEvent.CLICK, this.clickHandler);
            _loc_1.align = AlignMode.RIGHT;
            _loc_1.bold = false;
            this._numericStepper = UIFactory.gNumericStepper(100, 79, 50, 20, this, 99, 1, "NumericStepper", _loc_1);
            this._numericStepper.value = 1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._oldPrice.dispose(param1);
            this._price.dispose(param1);
            this._shopItem.dispose(param1);
            this._buyBtn.dispose(param1);
            this._propName.dispose(param1);
            this._numericStepper.dispose(param1);
            this._listPriceIcon.dispose(param1);
            this._priceIcon.dispose(param1);
            this._deleteLine.dispose(param1);
            this._yuanjia.dispose(param1);
            this._xianjia.dispose(param1);
            this._oldPrice = null;
            this._price = null;
            this._shopItem = null;
            this._buyBtn = null;
            this._propName = null;
            this._numericStepper = null;
            this._listPriceIcon = null;
            this._priceIcon = null;
            this._deleteLine = null;
            this._yuanjia = null;
            this._xianjia = null;
            this._info = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = new ShopQQData();
            _loc_2.amount = this._numericStepper.value;
            _loc_2.desc = this._info.desc;
            _loc_2.price = this._info.originPrice;
            _loc_2.type = this._info.type;
            _loc_2.id = this._info.id;
            _loc_2.name = this._info.name;
            if (this._info.type == 1)
            {
                _loc_2.url = "zuanshiBig.jpg";
            }
            else
            {
                _loc_2.url = ItemConfig.instance.getConfig(this._info.itemCode).url;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShopBuyQQItem, _loc_2));
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._info = param1.info as TTencentShop;
            if (this._info.type == 1)
            {
                this._shopItem.itemData = new ItemData(EPriceUnit._EPriceUnitGold);
            }
            else
            {
                this._shopItem.itemData = new ItemData(this._info.itemCode);
            }
            if (this._info.type == 1)
            {
                this._propName.text = this._info.name;
            }
            else
            {
                this._propName.htmlText = this._shopItem.itemData.itemInfo.htmlName;
            }
            this._oldPrice.text = this._info.originPrice.toString();
            this._price.text = this._info.discountPrice.toString();
            if (PlatformTencentUtil.getVipLevel() > 0)
            {
                this._deleteLine.visible = true;
                this._yuanjia.text = Language.getString(35546);
                this._price.htmlText = "<font color=\'#FAD200\'>" + this._info.discountPrice + "</font>";
                if (ParamsConst.instance.enterType == 1)
                {
                    this._xianjia.htmlText = Language.getString(35547);
                }
                else
                {
                    this._xianjia.htmlText = Language.getString(35642);
                }
            }
            else
            {
                this._deleteLine.visible = false;
                this._yuanjia.text = Language.getString(35548);
                this._price.text = "";
                if (ParamsConst.instance.enterType == 1)
                {
                    this._xianjia.htmlText = Language.getString(35549);
                }
                else
                {
                    this._xianjia.htmlText = Language.getString(35643);
                }
            }
            return;
        }// end function

    }
}
